package edu.gyc.security.async;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class MockQueue {

    private String placeOrder;
    private String completeOrder;

    public String getPlaceOrder() {
        return placeOrder;
    }

    public void setPlaceOrder(String placeOrder) {
     new Thread(new Runnable() {
         @Override
         public void run() {
             log.info("接到下单请求 "+placeOrder);
             try {
                 Thread.sleep(1000);
             } catch (InterruptedException e) {
                 e.printStackTrace();
             }
            MockQueue.this.setCompleteOrder(placeOrder);
             log.info("下单请求处理完毕 "+placeOrder);
         }
     }).start();
    }

    public String getCompleteOrder() {
        return completeOrder;
    }

    public void setCompleteOrder(String completeOrder) {
        this.completeOrder = completeOrder;
    }
}
